package org.gaaidou.ptarmigan.springboot.core.async;

import org.slf4j.MDC;

import java.util.Date;
import java.util.UUID;

public class ContextData {


    public static String getTxId() {
        return MDC.get("txId");
    }
    public static Date getStartTime() {
        return new Date(Long.parseLong(MDC.get("startTime")));
    }


    public static void clear() {
        MDC.clear();
    }

    public static void init() {
        MDC.put("txId", UUID.randomUUID().toString().replaceAll("-", ""));
        MDC.put("startTime", String.valueOf(new Date().getTime()));
    }
}
